package com.tg.paw.ums.controller;

import com.tg.paw.common.component.UserUtil;
import com.tg.paw.common.util.CommonResult;
import com.tg.paw.ums.dto.NavigatorMenu;
import com.tg.paw.ums.dto.UserInfoDto;
import com.tg.paw.ums.service.IAdminService;
import com.tg.paw.ums.service.IAdminUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "用户信息、权限", value = "AdminLoginController")
public class ApiAdminController {

    @Autowired
    private IAdminService adminService;

    @Autowired
    private IAdminUserService adminUserService;

    /**
     * 返回结果参见 /data/user.js
     * @return
     */
    @ApiOperation(value = "用户信息")
    @GetMapping("/userInfo")
    public CommonResult getUserInfo() {
        String username = UserUtil.getLoginUsername();

        UserInfoDto userInfoDto = adminUserService.getAdminInfo(username);

        return CommonResult.success(userInfoDto);
    }

    /**
     * data/navigatorMenu.js
     * @return
     */
    @ApiOperation(value = "动态路由 动态导航")
    @GetMapping("/navigator")
    public CommonResult navigator() {
        String username = UserUtil.getLoginUsername();

        List<NavigatorMenu> navigatorMenus = adminUserService.getAdminNavigator(username);

        return CommonResult.success(navigatorMenus);
    }



}
